USE [ServerMonitor]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[AllServerCurrentDiskFree]
AS
  SELECT SN.Name,SN.IP,SN.Instance,A.[Drive],A.[DiskFreeMB],A.[RecordTime]
  FROM [ServerMonitor].[dbo].[AllServerDiskFree] AS A INNER JOIN
  (SELECT MAX(RecordTime) AS RecordTime,[ServerId],[Drive]
  FROM [ServerMonitor].[dbo].[AllServerDiskFree]
  GROUP BY [ServerId],[Drive]) AS B
  ON A.[RecordTime] = B.RecordTime AND A.[Drive] = B.[Drive] AND A.[ServerId] = B.[ServerId]
  LEFT JOIN [ServerMonitor].[dbo].[Server] AS SN
  ON A.ServerId = SN.Id





GO


